package com.ruoyi.GoApply.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.GoApply.domain.GoApply;
import com.ruoyi.GoApply.service.IGoApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入驻申请Controller
 * 
 * @author ruoyi
 * @date 2024-09-03
 */
@RestController
@RequestMapping("/GoApply/GoApply")
public class GoApplyController extends BaseController
{
    @Autowired
    private IGoApplyService goApplyService;

    /**
     * 查询入驻申请列表
     */
    @PreAuthorize("@ss.hasPermi('GoApply:GoApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoApply goApply)
    {
        startPage();
        List<GoApply> list = goApplyService.selectGoApplyList(goApply);
        return getDataTable(list);
    }

    /**
     * 导出入驻申请列表
     */
    @PreAuthorize("@ss.hasPermi('GoApply:GoApply:export')")
    @Log(title = "入驻申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoApply goApply)
    {
        List<GoApply> list = goApplyService.selectGoApplyList(goApply);
        ExcelUtil<GoApply> util = new ExcelUtil<GoApply>(GoApply.class);
        util.exportExcel(response, list, "入驻申请数据");
    }

    /**
     * 获取入驻申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('GoApply:GoApply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(goApplyService.selectGoApplyById(id));
    }

    /**
     * 新增入驻申请
     */
    @PreAuthorize("@ss.hasPermi('GoApply:GoApply:add')")
    @Log(title = "入驻申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoApply goApply)
    {
        return toAjax(goApplyService.insertGoApply(goApply));
    }

    /**
     * 修改入驻申请
     */
    @PreAuthorize("@ss.hasPermi('GoApply:GoApply:edit')")
    @Log(title = "入驻申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public Object edit(@RequestBody GoApply goApply)
    {
        return goApplyService.updateGoApply(goApply);
    }

    /**
     * 删除入驻申请
     */
    @PreAuthorize("@ss.hasPermi('GoApply:GoApply:remove')")
    @Log(title = "入驻申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(goApplyService.deleteGoApplyByIds(ids));
    }
}
